<?php
/**
 * 获取新闻统计信息
 * 以json方式返回
 * solosky <solosky772@qq.com>
 */

include_once("common.php");

$pre    = $config["DB_PREX"]; 
//输出当前新闻
 $limit = getVar($_GET, "limit", 10, "int");
 $flag  = getVar($_GET, "flag", "latest");
 //$fields = getVar($_GET, "fields", "n.title,n.url,n.date");
$sql = "";

//根据不同的标志生成不同的SQL
switch($flag){
	//默认为最新新闻
	case "latest":
	default:$sql = "SELECT n.title,n.url,n.date,c.title AS category,s.title AS site FROM {$pre}news AS n, {$pre}category AS c, {$pre}site AS s WHERE n.categoryhash=c.categoryhash AND c.sitehash=s.sitehash ORDER BY date DESC LIMIT $limit";
}
 $suc = $db->query($sql);
 $rows = $db->getRows();
 $ret = array(
		"success" =>$suc,
		"data" =>$rows
	);
 exit(json_encode($ret));


?>